﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ICIA.ARojas.Silverlight.Shell;
using ICIA.ARojas.Visual.Usuario;

namespace EMI.GZClinica.Silverlight.Shell
{
    public partial class Principal : UserControl
    {
        public Principal()
        {
            InitializeComponent();
            btnAdminCurso.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnAdminCurso_Activate);
            btnAdminEspecialidad.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnAdminEspecialidad_Activate);
            btnAdminGrado.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnAdminGrado_Activate);
            btnAdminPersona.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnAdminPersona_Activate);

            btnUsuario.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnUsuario_Activate);
            btnCargo.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnCargo_Activate);

            btnDestino.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnDestino_Activate);

            this.Loaded += new RoutedEventHandler(MainPage_Loaded);

            btnCambiarClave.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnCambiarClave_Activate);


            ICIA.ARojas.Visual.Intermedio.Notificar.Current.OnNotificar += new EventHandler<ICIA.ARojas.Visual.Intermedio.NotificaLlamadaEventArgs>(Current_OnNotificar);


            btnReporteGestion.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnReporteGestion_Activate);

        }

        void btnReporteGestion_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.ReporteGestion.MainPage());
            f.CanMaximize = false;
            f.CanResize = false;
            f.Show(container);
        }

        void Current_OnNotificar(object sender, ICIA.ARojas.Visual.Intermedio.NotificaLlamadaEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.ReporteForm.MainPage(e.URL));
            f.Closed += new EventHandler(f_Closed);

            f.CanMaximize = false;
            f.IsMaximized = true;
            f.CanResize = false;
            f.Show(container);
        }


        void f_Closed(object sender, EventArgs e)
        {
            ICIA.ARojas.Visual.Intermedio.Notificar.Current.NotificarCerrado();
        }


        void btnCambiarClave_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {

            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.Usuario.VwCambiarContrasena());
            f.IsModal = true;
            f.CanMaximize = false;
            f.CanResize = false;
            f.Show(container);

        }

        void btnDestino_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.DestinoFisico.VwDestinoFisico());
            f.Show(container);
        }

        VwLogin login = new VwLogin();
        Didsoft.Silverlight.ContentManager.Form flogin;
        
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            login = new VwLogin();
            flogin = new Didsoft.Silverlight.ContentManager.Form(login);

            login.onLogueado += new EventHandler(login_onLogueado);
            flogin.CanMaximize = false;
            flogin.IsModal = true;
            flogin.CanClose = false;
            flogin.Show();
        }

        void login_onLogueado(object sender, EventArgs e)
        {
            flogin.Close();
        }

        void btnAdminPersona_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.Persona.MainPage());
            f.Show(container);
        }

        void btnAdminGrado_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.Grado.MainPage());
            f.Show(container);
        }

        void btnAdminEspecialidad_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.Especialidad.MainPage());
            f.Show(container);
        }

        void btnAdminCurso_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Silverlight.Curso.MainPage());
            f.Show(container);
        }

        void btnCargo_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.Cargo.VwCargo());
            f.Show(container);
        }

        void btnUsuario_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.Usuario.VwUsuario());
            f.Show(container);
        }

    }
}
